<template>
  <div id="feedback">
    <mt-field
      label="意见"
      placeholder="请输入您的意见"
      type="textarea"
      v-model="content"
      rows="4"
      >
    </mt-field>
    <mt-field label="邮箱" placeholder="xxx@xxx.xx" type="email" v-model="email"></mt-field>
    <mt-button @click="submit" id="submit" type="primary" size="large">提交</mt-button>
  </div>
</template>
<script>
import { Toast } from 'mint-ui';
import fetch from '@/libs/fetch';
export default {
  data(){
    return {
      content: '',
      email: ''
    }
  },
  methods:{
    submit(){
      fetch.post({
        url: '/commitView',
        data: {
          content: this.content,
          email: this.email,
          device: window.navigator.userAgent
        },
        success: (res) => {
          if(res.data.code === 0){
            Toast('反馈成功，我们会尽快处理，谢谢');
          }else{
            Toast(res.data.msg);
          }
        },
        error: (e) => {
          Toast('网络故障，请稍后重试');
        }
      })
    }
  }
}
</script>
<style scoped>
#feedback{
  padding: 10px;
  box-sizing: border-box;
}
#submit{
  margin-top: 20px;
}
</style>
